1 package org.smartcomps.twister.engine.core.dynamic; 2 3 import junit.framework.TestCase; 4 import net.sf.hibernate.tool.hbm2ddl.SchemaExport; 5 import net.sf.hibernate.cfg.Configuration; 6 import org.smartcomps.twister.common.transaction.TransactionManager; 7 import org.smartcomps.twister.common.lifecycle.LifecycleManager; 8 import org.smartcomps.twister.engine.core.definition.TestProcess; 9 import org.smartcomps.twister.engine.core.definition.TestWait; 10 import org.smartcomps.twister.engine.priv.core.dynamic.ProcessInstanceFactory; 11 import org.smartcomps.twister.engine.priv.core.dynamic.ProcessInstance; 12 import org.smartcomps.twister.engine.priv.core.dynamic.ExecutionContextFactory; 13 14 import java.util.Map; 15 import java.util.HashMap; 16 17 public class TestProcessInstance extends TestCase { 18 19 public static ProcessInstance testProcessInstance = null; 20 21 private TestProcess testProcess = new TestProcess(); 22 private TestWait testWait = new TestWait(); 23 24 protected void setUp() throws Exception { 25 LifecycleManager.getLifecycleManager().createResources(); 26 LifecycleManager.getLifecycleManager().startResources(); 27 28 SchemaExport schemaExport = new SchemaExport(new Configuration().configure()); 29 schemaExport.create(true, true); 30 31 TransactionManager.beginTransaction(); 32 testProcess.testCreateWithCorrelation(); 33 testWait.testCreate(); 34 } 35 36 protected void tearDown() throws Exception { 37 TransactionManager.commitTransaction(); 38 39 LifecycleManager.getLifecycleManager().stopResources(); 40 LifecycleManager.getLifecycleManager().destroyResources(); 41 } 42 43 public void testCreate() throws Exception { 44 Map corrProp = new HashMap(); 45 corrProp.put(TestProcess.CORRELATION_PROP1, "2578"); 46 corrProp.put(TestProcess.CORRELATION_PROP2, "12"); 47 ProcessInstance pi = ProcessInstanceFactory.createProcessInstance(TestProcess.testProcess, 48 TestProcess.CORRELATION_NAME, corrProp); 49 50 ExecutionContextFactory.createExecutionContext(TestWait.wait, pi); 51 52 TransactionManager.commitTransaction(); 53 TransactionManager.beginTransaction(); 54 55 ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp); 56 assertEquals("Created process instance doesn't have two properties", 2, createdInstance.getProperties().size()); 57 assertEquals("First property doesn't have same value", "2578", createdInstance.getPropertyFromName(TestProcess.CORRELATION_PROP1).getValue()); 58 assertEquals("Second property doesn't have same value", "12", createdInstance.getPropertyFromName(TestProcess.CORRELATION_PROP2).getValue()); 59 60 } 61 62 }

This page was automatically generated by Maven